package com.zhonghui.mes.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.zhonghui.common.utils.SecurityUtils;
import com.zhonghui.mes.domain.vo.MesMaterialInspectorVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhonghui.mes.mapper.MesMaterialInspectorMapper;
import com.zhonghui.mes.domain.MesMaterialInspector;
import com.zhonghui.mes.service.IMesMaterialInspectorService;

/**
 * 来料检验Service业务层处理
 * 
 * @author zhonghui
 * @date 2022-05-22
 */
@Service
public class MesMaterialInspectorServiceImpl implements IMesMaterialInspectorService 
{
    @Autowired
    private MesMaterialInspectorMapper mesMaterialInspectorMapper;

    /**
     * 查询来料检验
     * 
     * @param id 来料检验主键
     * @return 来料检验
     */
    @Override
    public MesMaterialInspectorVo selectMesMaterialInspectorById(Long id)
    {
        return mesMaterialInspectorMapper.selectMesMaterialInspectorById(id);
    }

    /**
     * 查询来料检验列表
     * 
     * @param mesMaterialInspectorVo 来料检验
     * @return 来料检验
     */
    @Override
    public List<MesMaterialInspectorVo> selectMesMaterialInspectorList(MesMaterialInspectorVo mesMaterialInspectorVo)
    {
        return mesMaterialInspectorMapper.selectMesMaterialInspectorList(mesMaterialInspectorVo);
    }

    /**
     * 新增来料检验
     * 
     * @param mesMaterialInspector 来料检验
     * @return 结果
     */
    @Override
    public int insertMesMaterialInspector(MesMaterialInspector mesMaterialInspector)
    {
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        mesMaterialInspector.setSerialNumber("LLJY" + format.format(date));
        mesMaterialInspector.setCheckUserId(SecurityUtils.getUserId());
        mesMaterialInspector.setInspectorTime(new Date());
        return mesMaterialInspectorMapper.insertMesMaterialInspector(mesMaterialInspector);
    }

    /**
     * 修改来料检验
     * 
     * @param mesMaterialInspector 来料检验
     * @return 结果
     */
    @Override
    public int updateMesMaterialInspector(MesMaterialInspector mesMaterialInspector)
    {
        return mesMaterialInspectorMapper.updateMesMaterialInspector(mesMaterialInspector);
    }

    /**
     * 批量删除来料检验
     * 
     * @param ids 需要删除的来料检验主键
     * @return 结果
     */
    @Override
    public int deleteMesMaterialInspectorByIds(Long[] ids)
    {
        return mesMaterialInspectorMapper.deleteMesMaterialInspectorByIds(ids);
    }

    /**
     * 删除来料检验信息
     * 
     * @param id 来料检验主键
     * @return 结果
     */
    @Override
    public int deleteMesMaterialInspectorById(Long id)
    {
        return mesMaterialInspectorMapper.deleteMesMaterialInspectorById(id);
    }
}
